<?php
namespace app\index\controller;
use think\Controller;

class Chtml extends Controller
{
	
		//生成静态
	public function createHtml(){	
		action('index/index/doindex');
		$htmlName = 'index.html'; 	   //生成静态文件名称
		$path = ''; 							 //首页生成到html目录下面
		$htmlPath = ROOT_PATH.$path.'/'.$htmlName; //生成静态文件路径
		$this->filePutContents($htmlPath,'index');	
		echo '生成首页:'.$htmlPath;
		$this->success("生成成功",url('Index/index'));
	}

	//生成静太文件
	private function filePutContents($htmlPath,$tpl){
		ob_start();		
		$content = $this->fetch('index@index/'.$tpl);
		echo $content;
		$_cache=ob_get_contents();
		ob_end_clean();
		if($_cache){
			$File = new \think\template\driver\File();
			$File->write($htmlPath, $_cache);
		}
	}

		
}
